//
//  TechnologyDetailViewController.m
//  Blank
//
//  Created by 周星宇 on 15/9/28.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "TechnologyDetailViewController.h"
#import "AFNetWorkingGet.h"

@interface TechnologyDetailViewController () <UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;

@end

@implementation TechnologyDetailViewController

- (void)dataHandle{
    self.url = [NSString stringWithFormat:MoreCultureDetailURL, self.cid];
    [AFNetWorkingGet GETWithAFNByURL:self.url completion:^(id result) {
        
    }];
    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
    [_webView loadRequest:request];
    /* 关闭反弹效果 */
    self.webView.scrollView.bounces = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, -84 * Height, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height + 145 * Height)];
    [self.view addSubview: self.webView];
    self.webView.delegate = self;
    [self dataHandle];
    [self withNavigationItem];
}

- (void)withNavigationItem{
    UIButton *leftMenuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftMenuBtn.frame = CGRectMake(0, 0, 25 * Windth, 25 * Height);
    [leftMenuBtn setBackgroundImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:UIControlStateNormal];
    [leftMenuBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftMenuBtn];
}

- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    if ([NightModel getColorModel]) {
        [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'white'"];
        //页面背景色
        [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='gray'"];
    }
}

- (void)viewWillAppear:(BOOL)animated{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
